<?
require_once("conn.php");
?>
<h3>รายการของค้างส่ง</h3>
<table width="100%">
	<tr>
		<td>Order ID</td>
		<td>Barcode</td>
		<td>รายการสินค้า</td>
		<td>Product Name</td>
		<td>Amount</td>
		<td>Order Date</td>
		<td>รวมค้างส่ง</td>
		<td>&nbsp;</td>
	</tr>
	<?
		$sql = "select a.id as id,barcode,order_id,item,th,mm,amount,orderTime,DATEDIFF(DATE(now()),orderTime) AS DiffDate FROM pch_unfinished as a join product as b on a.item=b.id;";
		$query = mysql_query($sql);
		if(mysql_num_rows($query) > 0){
			while($row = mysql_fetch_array($query)){
				if($row["DiffDate"] > 3){
					$diff = '<span align="center" style="font-weight:bold;color:red;">'.$row["DiffDate"].'</span>';
				}else{
					$diff = $row["DiffDate"];
				}
			?>
				<tr>
					<td><?=$row["order_id"]?></td>
					<td><?=$row["barcode"]?></td>
					<td><?=$row["th"]?></td>
					<td><?=$row["mm"]?></td>
					<td><?=$row["amount"]?></td>
					<td><?=$row["orderTime"]?></td>
					<td><?=$diff?> วัน</td>
					<td><a href="#" onclick="delUnfinished('<?=$row["id"]?>')">Clear</a></td>
				</tr>
			<?
			}
		}else{
		?>
			<tr><td colspan="8">ไม่มีรายการค้างส่ง</td></tr>
		<?
		}
		?>
</table>